package com.qiangesoft.blog.controller.manage;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qiangesoft.blog.common.annotation.OperationLog;
import com.qiangesoft.blog.common.constants.FieldConstants;
import com.qiangesoft.blog.system.entity.SysWebConfig;
import com.qiangesoft.blog.system.service.ISysWebConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 网站配置表 前端控制器
 * </p>
 *
 * @author qiange
 */
@RestController
@RequestMapping("/system/webConfig")
@Api(tags = "网站配置管理")
@RequiredArgsConstructor
public class SysWebConfigController {

    private final ISysWebConfigService webConfigService;

    @PutMapping
    @ApiOperation(value = "修改网站配置")
    @OperationLog(value = "修改网站配置")
    public void update(@RequestBody SysWebConfig webConfig) {
        webConfigService.updateWebConfig(webConfig);
    }

    @GetMapping
    @ApiOperation(value = "获取网站配置")
    public SysWebConfig getConfig() {
        return webConfigService.getOne(new LambdaQueryWrapper<SysWebConfig>().last(FieldConstants.LIMIT_ONE));
    }
}

